#include "Vec3d.h"

Vec3d::Vec3d()
{
	this->x = 0.0f;
	this->y = 0.0f;
	this->z = 0.0f;
}

Vec3d::Vec3d(float x, float y, float z)
{
	this->x = x;
	this->y = y;
	this->z = z;
}

Vec3d Vec3d::operator+(const Vec3d &other) const
{
	Vec3d sum(this->x + other.x, this->y + other.y, this->z + other.z);
	return sum;
}

Vec3d Vec3d::operator-(const Vec3d &other) const
{
	Vec3d difference(this->x - other.x, this->y - other.y, this->z - other.z);
	return difference;
}

float Vec3d::operator*(const Vec3d &other) const
{
	return ((this->x * other.x) + (this->y * other.y) + (this->z * other.z));
}

void Vec3d::normalize()
{
	float factor = invSqrt((this->x * this->x) + (this->y * this->y) + (this->z * this->z));
	this->x *= factor;
	this->y *= factor;
	this->z *= factor;
}